<%-- 
    Document   : index
    Created on : Apr 2, 2013, 8:24:17 PM
    Author     : T-Rain
--%>

<%@page import="java.text.DecimalFormat"%>
<%@page import="java.text.DecimalFormatSymbols"%>
<%@page import="TrangSuc.Giohang"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="Func.Conn"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <%@ include file="head.jsp" %>

<body>
<div id="divContainer">
    
    <%@ include file="divHeader.jsp" %>
	
    </br>		
    <div class="clr"></div>
				
    <%@ include file="divLeft.jsp" %>
        
<%
        DecimalFormatSymbols decimalFormatSymbols = new DecimalFormatSymbols();
        decimalFormatSymbols.setDecimalSeparator('.');
        decimalFormatSymbols.setGroupingSeparator(',');
        DecimalFormat decimalFormat = new DecimalFormat("#,##0", decimalFormatSymbols);
%>
	<div id = "divMid">
            <div id ="pro4">
                <%
     
                Connection con = Conn.GetCon();
 Statement statement = con.createStatement();
 Statement statement1 = con.createStatement();
 ResultSet resultSet1 ;

// Execute a statement
 ResultSet resultSet = statement.executeQuery
 ("select * from thongtinsanpham,thongtinchungloai where thongtinsanpham.machungloai = thongtinchungloai.machungloai  ");
out.println("<table class='show' width='97%' border='0' align='center' >");
out.println("<tr align = 'center'>");
int x = 0;
String url = "";
// Iterate through the result and print the student names
while (resultSet.next())
    
      {
x+=1;    
    out.println("<td class = 'show'>");
    if(  resultSet.getInt("makhuyenmai") == 0)
               {
        url =  resultSet.getString("urlhinh") + "1s.jpg";
out.println("<a href ='chitietsp.jsp?id="+resultSet.getString("MaSP")+"'><img src ="+url+" height ='225px' weight ='225px'></a><br>" );
out.println(""+ resultSet.getString("TenChungLoai")+"<br>");
out.println("Giá :"+ decimalFormat.format(resultSet.getInt("Gia"))+" VND <br>");
out.println("Số lượng có hạn");

    }
 else
         {
        
        url =  resultSet.getString("urlhinh") + "1-" + resultSet.getInt("makhuyenmai") + ".jpg";
out.println("<a href ='chitietsp.jsp?id="+resultSet.getString("MaSP")+"'><img src ="+ url +"></a><br>" );
out.println(""+ resultSet.getString("TenChungLoai")+"<br>");
out.println("Giá khuyến mãi :"+ decimalFormat.format((resultSet.getDouble("Gia") - (resultSet.getDouble("Gia")* resultSet.getDouble("MaKhuyenMai"))/10)) +" VND  <br>");
out.println("Giá cũ :<b class='gia'>"+ decimalFormat.format(resultSet.getInt("Gia")) +"</b> VND  <br>");
 
 }

out.println("<table border='0' width ='97%' >");
out.println  ("<tr><td >");
out.println("<center><form action = 'Xuly?act=cart&id="+ resultSet.getString("MaSP") +"&sl=1' method = 'post'>");
out.println("<input class='btmua' type=\"submit\" value=\"Mua Hàng\">");

out.println("</form></center>");
out.println("</td>");
out.println("</tr>");
out.println("</table>");

out.println("</td>");
    if(x ==3)
		 {
			 x = 0;
            out.println("</tr>"); 
	out.println("<tr align='center'>");		 
        }
}       
out.println("</tr></table>");
               %> 
               </div>
        </div>
       
<%@ include file="divFooter.jsp" %>      
</div>
               

    </body>
</html>
